import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, DelDataButton } from '../Common/options'

export const EnvironmentData = async ({ url, OptionsEvent, Permission, ClientData }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === 'e3383598-4c81-4c5f-8266-fd592db2c58c') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            commonTableList.tableName,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'pm25',
                title: 'PM2.5',
                valueType: 'inputNumber',
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'pm10',
                title: 'PM10',
                valueType: 'inputNumber',
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'noise',
                title: '噪声',
                valueType: 'inputNumber',
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'temperature',
                title: '温度',
                valueType: 'inputNumber',
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'humidity',
                title: '湿度',
                valueType: 'inputNumber',
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'windSpeed',
                title: '风速',
                valueType: 'inputNumber',
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'windDirection',
                title: '风向',
                valueType: 'input',
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'windLevel',
                title: '风级',
                valueType: 'inputNumber',
                width: 150,
                hideInSearch: true,
            },

            {
                dataIndex: 'online',
                title: '在线状态',
                valueType: 'select',
                valueEnum: BuiltInData.online,
                rules: true,
                hideInSearch: true,
                width: 150,
            },
            {
                dataIndex: 'warning',
                title: '报警状态',
                valueType: 'select',
                valueEnum: BuiltInData.warning,
                rules: true,
                width: 150,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            commonTableList.BeginStatDate,
            commonTableList.EndStatDate,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '6d895066-1e4d-42a5-9353-166826d535ae') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
